package main

import (
	"GoLearn2024/day03/06_grpc/pb"
	"context"
	"fmt"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

func main() {
	// 建立grpc连接
	conn, err := grpc.Dial("127.0.0.1:8082", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		panic(err)
	}
	defer conn.Close()
	// 建立一个grpc服务的clinet
	client := pb.NewMessageSenderClient(conn)
	resp, err := client.Send(context.Background(), &pb.MessageRequest{SaySomething: "Hello World"})
	if err != nil {
		panic(err)
	}
	fmt.Println("receive message", resp.ResponseSomething)

}
